package com.draven.order.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.draven.order.entity.Order;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderMapper extends BaseMapper<Order> {
    @Select("select * from orders")
    List<Order> selectAll();

    @Select("select * from orders where id = #{id}")
    Order selectById(Long id);

    @Update("update orders set name = #{name}, price = #{price}, address = #{address} where id = #{id}")
    int updateOrder(Order order);

    @Delete("delete from orders where id = #{id}")
    void deleteById(Long id);

    @Delete("delete from orders where id in (${ew.customSqlSegment})")
    void deleteBatchIds(@Param(Constants.WRAPPER) Wrapper<Order> wrapper);

}
